home *** CD-ROM | disk | FTP | other *** search
- RSCFIX.C -- A resource fixer for code-resident resources.
-
- RSCFIX.C contains a set of routines to prepare a code-resident
- resource for use. It was derived from STCREATE.C, found in the
- RSCREATE folder on the Resource Disk supplied with the Atari
- Developer's Kit.
-
- The routines are driven by a main routine, rsc_fix(), which you
- call during your program initialization to prepare the resource.
- The routines perform 2 distinct functions on the resource. The
- first is to change all the offsets, generated by RSC, to address
- pointers. The second function is to change all the object
- rectangle coordinates and sizes from characters to pixels,
- according to the current screen resolution.
-
- First get the download the file RSCFIX.C and put it with your
- header files. (e.g. on the compiler disk with ALCYON, in the
- HEADERS folder with Megamax, in the INCLUDE folder with Micro-C
- Shell and Mark Williams C, etc.)
-
- Next, create the C source file using RCS or RCS2. To do this,
- run the RCS program, Open your resource file, select the Output
- option from the Global menu, select '.H' and '.C' ('.RSH' for
- RCS2), click on OK, and Close your resource. Put the these files
- with your source file(s).
-
- Then, modify your source file to include the resource's C source
- and header files and 'RSCFIX.C'. Change your call to rsrc_load()
- to rsc_fix(). Change your call to rsrc_gaddr to load the tree
- pointer from the rs_trindex[] array.
-
- Limitations: The 'adj' macro takes care of objects that are not
- character aligned but seems to have trouble when the root object
- of a tree is NOT character aligned. Just make sure all your root
- objects are character aligned and you should not have any
- problems.
-
- The following code fragment illustrates the use of rsc_fix().
-
- #include <obdefs.h>
- #include <gemdefs.h>
- .
- .
- .
- #ifndef BYTE /* Take care of 'portability' */
- #define BYTE char /* macros in the '.RSH' file. */
- #define WORD int
- #define LONG long
- #endif
-
- #include "resource.h" /* The header file from RSC */
- #include "resource.rsh" /* The C source file from RSC */
-
- OBJECT *tree; /* Pointer to an object tree */
- .
- .
- /* global declarations */
- .
- .
- #include <rscfix.c> /* Code to fixup resource */
-
- void sort(v,n)
- char *v[];
- int n;
- {
- .
- .
- }
- .
- .
- .
- void do_form( rsc_tree, exit_obj )
- int rsc_tree;
- int exit_obj;
- {
- int xdial, ydial, wdial, hdial;
- int x, y, w, h;
- int object;
-
- tree = (OBJECT *) rs_trindex[ rsc_tree ];
-
- form_center( tree, &xdial, &ydial, &wdial, &hdial );
- x = xdial + wdial/2;
- y = ydial + hdial/2;
- w = gl_wbox;
- h = gl_hbox;
- form_dial( 0, x, y, w, h, xdial, ydial, wdial, hdial );
- form_dial( 1, x, y, w, h, xdial, ydial, wdial, hdial );
-
- objc_draw( tree, ROOT, MAX_DEPTH, xdial, ydial, wdial, hdial );
-
- object = 0;
-
- while( object != exit_obj )
- {
- object = form_do( tree, 0 ) & 0x7FFF;
- handle_object( tree, object );
- .
- .
- .
- }
-
- form_dial( 2, x, y, w, h, xdial, ydial, wdial, hdial );
- form_dial( 3, x, y, w, h, xdial, ydial, wdial, hdial );
- }
-
- main()
- {
- if ( appl_init() >= 0 )
- {
- rsc_fix();
- .
- .
- graf_mouse( M_ON, 0x0L );
- graf_mouse( ARROW, 0x0L );
- do_form( TREE0, OKBUTTON );
- .
- .
- appl_exit();
- }
- }
- əəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəəə